//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.lyq.bean.mySql;

import com.lyq.bean.Elective;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class SeekElectStuentNo_Sql {
    public SeekElectStuentNo_Sql() {
    }

    public List<Elective> seekElectStuentNo_Sql(String cNo) {
        (new MysqlLinking()).getLink();
        Connection conn = MysqlLinking.conn;
        List<Elective> list = new ArrayList();
        if (conn != null) {
            try {
                String sql = "SELECT ec.S_No, ec.C_Name, s.S_Name " +
                             "FROM electcourse ec " +
                             "JOIN student s ON ec.S_No = s.S_No " +
                             "WHERE ec.C_No=?";
                PreparedStatement ps = conn.prepareStatement(sql);
                ps.setString(1, cNo);
                ResultSet rs = ps.executeQuery();

                while(rs.next()) {
                    Elective e = new Elective();
                    e.setsNo(rs.getString("S_No"));
                    e.setcName(rs.getString("C_Name"));
                    e.setsName(rs.getString("S_Name"));
                    list.add(e);
                }
            } catch (Exception var8) {
                Exception e = var8;
                e.printStackTrace();
            }
        } else {
            System.out.println("数据库连接错误！");
        }

        return list;
    }
}